package com.neulogistics.core.substation.api.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.blackto.lib.mediat.core.IMediator;
import com.neulogistics.core.substation.api.application.command.CreateTaskOrderCommand;
import com.neulogistics.core.substation.api.application.query.ISubstationPaymentQueryService;
import com.neulogistics.core.substation.api.application.query.ISubstationQueryService;
import com.neulogistics.core.substation.api.application.query.SubstationPaymentQuery;
import com.neulogistics.core.substation.api.application.query.SubstationQuery;
import com.neulogistics.core.substation.api.application.viewmodel.SubstationPaymentViewModel;
import com.neulogistics.core.substation.api.application.viewmodel.SubstationViewModel;
import com.neulogistics.core.substation.infrastructure.persistence.orm.service.ISubstationPaymentPOService;
import com.neulogistics.infrastructure.common.serviceresult.BaseResponse;
import com.neulogistics.infrastructure.common.serviceresult.ResultUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;

@RestController
@Api(tags = "分站缴款单管理")
@RequestMapping("/substation/payment")
public class SubstationPaymentController {
    @Resource
    private IMediator mediator;

    @Resource
    ISubstationPaymentQueryService substationPaymentQueryService;

    @ApiOperation("根据id查询分站缴款单")
    @PostMapping("/get/{id}")
    public BaseResponse<SubstationPaymentViewModel> get(@PathVariable(value = "id") @NotNull @Positive Long id){
        // 已校验数据格式

        SubstationPaymentViewModel substationPaymentViewModel = substationPaymentQueryService.getById(id);
        return ResultUtils.success(substationPaymentViewModel);
    }

    @ApiOperation("分页查询分站缴款单")
    @PostMapping("/page")
    public BaseResponse<Page<SubstationPaymentViewModel>> page(@RequestBody @NotNull @Validated SubstationPaymentQuery substationPaymentQuery){
        // 已校验数据格式

        Page<SubstationPaymentViewModel> viewModelPage = substationPaymentQueryService.page(substationPaymentQuery);
        return ResultUtils.success(viewModelPage);
    }
}
